<!--
*@Author: zt
*@Description: 文件夹新增或编辑
*@Date: 2024-08-19
-->
<template>
  <u-dialog v-bind="$attrs" title="文件详细" @submit="submit">
      <a-form-item label="文件名">
        <u-input v-model:value="form.foldername"></u-input>
      </a-form-item>
  </u-dialog>
</template>

<script lang="ts" setup>
import { ref, reactive, computed, onMounted, h, watch, useAttrs } from "vue";
import { _IFormEl, _IExtra } from "@/src/components/common/form/interface";
import { _IColumnProps } from "@/components/common/tableEdit/interface.ts";
import { fileCols } from "@/common/model/fileCols";
import * as docApi from "@/service/assist/doc";
import * as docDtailApi from "@/service/assist/docDetail";
import { alertC } from "@/util/common";
const emit = defineEmits(["success"]);
const attrs = useAttrs();

let form = reactive<any>({
  foldername: "",
  orderno:1
});

// 提交
const submit = async () => {
  const url = form.keyid ? 'update' : 'add';

 await docApi[url](form).then(res => {
          if(res.code == 0) {
            alertC(res.msg, "success");
            emit('success')
            form.foldername = ''
            form.keyid = ''
          }
          else {
            alertC(res.msg, 'warning');
          }
        })
        .catch(err => {})
};

watch(
  () => attrs.open,
  async (nval, oval) => {
    if (nval == true) {
      if(attrs.keyid){
        form.foldername = attrs.foldername
        form.keyid = attrs.keyid
      }
    }
  }
);
</script>

<style lang="scss"></style>
